/*
   Chiroptera - A Java client for Bacula

   The main author of Chiroptera is Marcos Paulo Serafim.
   This program is Free Software; you can redistribute it and/or
   modify it under the terms of version two of the GNU General Public
   License as published by the Free Software Foundation and included
   in the file LICENSE.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
   02110-1301, USA.
*/
package br.eti.mps.chiroptera.lib;

/**
 *
 * @author <a href="mailto:mpserafim[at]gmail[dot]com">Marcos Paulo Serafim</a>
 */
public class Data {

	private String data;
	private int signal;
	
	public Data() {
	}
	
	public Data(String data) {
		this.data = data;
	}
	
	public int getDataSize() {
		return data.length();
	}
	
	public String getMessage() {
		if (data != null && data.length() > 5) {
			return data.substring(5);
		}
		return null;
	}
	
	public int getReturnCode() {
		if (data == null && data.length() < 4) {
			return 0;
		}
		int rc = 0;
		try {
			rc = Integer.parseInt(data.substring(0, 4));
		} catch (NumberFormatException ne) {}
		return rc;
	}
	
	public String getData() {
		return data;
	}
	
	public void setData(String data) {
		this.data = data;
	}

	public int getSignal() {
		return signal;
	}

	public void setSignal(int signal) {
		this.signal = signal;
	}
	
}
